<?php
namespace App\Api\Phalapitencentsms;

use PhalApi\Api;
use App\Domain\Phalapitencentsms\Main as SmsDomain;

/**
 * 腾讯云短信插件
 * @author yourname
 */
class Main extends Api
{
    public function getRules()
    {
        return array(
            'tencentSendSms' => array(
                'PhoneNumbers' => array('name' => 'PhoneNumbers', 'require' => true, 'desc' => '接收短信的手机号码。国内短信：11位手机号码，例如15951955195。国际/港澳台消息：国际区号+号码，例如85200000000。'),
                'TemplateId' => array('name' => 'TemplateId', 'require' => true, 'desc' => '短信模板ID。'),
                'TemplateParam' => array('name' => 'TemplateParam', 'type' => 'array', 'format' => 'json', 'desc' => '短信模板变量对应的实际值，JSON格式。例如：{"code":"1111"}'),
                'SdkAppId' => array('name' => 'SdkAppId', 'require' => true, 'desc' => '短信SdkAppId'),
                'SignName' => array('name' => 'SignName', 'require' => true, 'desc' => '短信签名名称。')
            ),
        );
    }

    /**
     * 腾讯云发送短信接口
     * @desc 通过腾讯云的短信接口发送短信。
     * @return string 短信发送结果
     */
    public function tencentSendSms()
    {
        $sms = new SmsDomain();
        $smsRs = $sms->tencentSendSms($this->PhoneNumbers, $this->TemplateId, $this->TemplateParam, $this->SdkAppId, $this->SignName);
        return $smsRs;
    }
}